import Vue from 'vue'
import App from './App.vue'
import router from './router'

// import './plugins/element.js'
//todo 引入字体css
import './assets/fonts/iconfont.css'
// todo引入全局css
import './assets/css/global.css'
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)

// todo 导入进度条插件
import NProgress from 'nprogress'
// 项目优化后css在index.html中引入
import 'nprogress/nprogress.css'


// todo 引入axios
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
Vue.prototype.$http = axios
// a 请求拦截器
// *在请求拦截器时加入进度条插件
axios.interceptors.request.use(config => {
  if (config.url != 'login') {
    config.headers.Authorization = window.sessionStorage.getItem('token');
  }
  NProgress.start();
  return config
})
// *在响应拦截器时加入进度条插件
axios.interceptors.response.use(config => {
  NProgress.done();
  return config
})



// todo 全局定义时间过滤器
Vue.filter('dateFormat', function (orginVal) {
  const dt = new Date(orginVal);
  const y = dt.getFullYear();
  const mon = (dt.getMonth() + 1 + '').padStart(2, '0');
  const day = (dt.getDate() + '').padStart(2, '0');
  const h = (dt.getHours() + '').padStart(2, '0');
  const m = (dt.getMinutes() + '').padStart(2, '0');
  const s = (dt.getSeconds() + '').padStart(2, '0');

  return `${y}-${mon}-${day} ${h}:${m}:${s}`
})

// todo导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本编辑器样式 优化后加在index.html中
// import 'quill/dist/quill.core.css' // import styles
// import 'quill/dist/quill.snow.css' // for snow theme
// import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
